<template>
  <div class="setting">
    <van-nav-bar title="设置" left-arrow @click-left="back" />
    <div class="container">
      <ul>
        <li v-tap="{methods:myinfo}">
          <span>个人资料</span>
          <van-icon name="arrow" />
          <div class="header">
            <img :src="info.uheader" alt />
          </div>
        </li>
        <li>
          <span>账户安全</span>
          <van-icon name="arrow" />
        </li>
        <li>
          <van-cell-group>
            <van-switch-cell v-model="checked" title="消息推送提醒" />
          </van-cell-group>
        </li>
        <li>
          <span>问题反馈</span>
          <van-icon name="arrow" />
        </li>
        <li>
          <span>推荐给朋友</span>
          <van-icon name="arrow" />
        </li>
        <li>
          <span>关于我们</span>
          <van-icon name="arrow" />
        </li>
      </ul>

      <div class="exits" v-tap="{methods:exit}">退出登录</div>
    </div>
  </div>
</template>

<script>
import * as api from "../api/User";
import { Dialog } from "vant";
import { Toast } from 'vant';
export default {
  name: "setting",
  data() {
    return {
      checked: false,
      info: {}
    };
  },
  methods: {
    back() {
      this.$router.go(-1);
    },
    myinfo() {
      this.$router.push("/myinfo");
    },
    exit() {
      // localStorage.removeItem("token");
      Dialog.confirm({
        title: "提示",
        message: "您真的要退出吗？"
      })
        .then(() => {
          localStorage.removeItem("token");
          this.$router.push("/login");
        })
        .catch(() => {
          Toast('退出成功');
        });
    }
  },
  mounted() {
    api.getOneUser().then(data => {
      this.info = data.data.result[0];
      if (this.info.uheader == "null" || this.info.uheader == null) {
        this.info.uheader =
          "http://47.96.143.29/img/default.jpeg";
      }
    });
  }
};
</script>

<style scoped>
.van-ellipsis {
  font-size: 30px;
}
.van-icon {
  color: #333;
}
.container {
  width: 100%;
  padding-top: 10px;
}

.container ul {
  background: #fff;
}
.container ul li {
  height: 120px;
  width: 100%;
  box-sizing: border-box;
  line-height: 120px;
  padding: 0 30px;
  position: relative;
  border-bottom: solid 1px #eee;
}
.container ul li .header {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  float: right;
  margin-right: 20px;
  margin-top: 20px;
}
.container ul li .header img {
  width: 100%;
}
.container ul li span {
  float: left;
  font-size: 28px;
}
.container ul li .van-icon {
  float: right;
  margin-top: 45px;
  font-size: 28px;
}
.container .exits {
  width: 90%;
  height: 100px;
  background: #000;
  color: #fff;
  text-align: center;
  line-height: 100px;
  font-size: 28px;
  position: absolute;
  left: 5%;
  bottom: 5%;
}
.van-switch-cell {
  padding: 0;
}
.van-cell {
  line-height: inherit;
}
</style>